local joy__juyi = fk.CreateSkill {

  name = "joy__juyi",

  tags = { Skill.Limited, },

}



joy__juyi:addEffect(fk.EventPhaseStart, {
  name = "joy__juyi",
  frequency = Skill.Limited,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player.maxHp > #player.room.alive_players and player:hasSkill(joy__juyi.name) and
     player.phase == Player.Start and player:usedSkillTimes(joy__juyi.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, joy__juyi.name)
  end,
  on_use = function(self, event, target, player, data)
    local n = player.maxHp - #player.player_cards[Player.Hand]
    if n > 0 then
      player:drawCards(n, joy__juyi.name)
    end
    player.room:handleAddLoseSkills(player, "joy__benghuai|ty_ex__weizhong")
  end,
})

return joy__juyi